extends "LogicBase.gd"

enum {S_gameStart,S_playerTurnBegin,S_playerTurnExecute,S_playerTurnExecuteEnd,S_playerTurnEnd,
	S_enemyTurnBegin,S_enemyTurnExecute,S_enemyTurnEnd}
var state=-1 setget set_state

func set_state(value):
    #离开状态事件
	match state:
		S_playerTurnExecute:
			get_battle().turnEndButton.disabled=true
			get_cardSystem().playerTurnEnd()
    #改变状态值
	state=value
    #进入状态事件
	match state:
		S_gameStart: #游戏开始，只会执行一次
            
			pass
		S_playerTurnBegin: #玩家回合开始
			for player in getPlayers():
				var a=player.armor/2
				setProperty(player,"armor",a)
            
		S_playerTurnExecute: #玩家操作阶段
			get_cardSystem().turnBegin()
			get_battle().turnEndButton.disabled=false

		S_playerTurnExecuteEnd: #玩家点了回合结束按钮之后切换到这个状态，在这里等待动画播放结束，之后进入下一阶段
            
			pass
		S_playerTurnEnd:
			pass
		S_enemyTurnBegin:
			pass
		S_enemyTurnExecute:
			pass
		S_enemyTurnEnd:
			pass
    
func execute():
	set_state(S_gameStart)
func process():
	if state==S_playerTurnExecute:
        #什么都不做 这是等待玩家按下回合结束按钮进入下一阶段
		pass
	else:
        #每个阶段都会等待动画完成，自动跳到下个阶段
		if !get_battle().isPlaying && get_battle().donghuaList.size()==0:#动画完成
			var nextState=state+1
			if nextState>S_enemyTurnEnd:
				nextState=S_playerTurnBegin
			set_state(nextState)



   

#按下了回合结束按钮
func onPlayerTurnEndButton():
	if state==S_playerTurnExecute:
		set_state(S_playerTurnExecuteEnd)
    

